package com.leetcode.offer;

import com.leetcode.code.LeetCode0054Java;

/**
 * Description:
 *
 * @author zkingcobra
 * Date: 2020/6/5 10:15 上午
 * @see LeetCode0054Java
 */
public class Offer0046Java {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.printf("%d%n", solution.translateNum(112233));
    }

    /**
     * 方法一 动态规划
     */
    private static class Solution {

        public int translateNum(int num) {
            String s = String.valueOf(num);

            int a = 1, b = 1;

            for (int i = 2; i <= s.length(); i++) {
                String tmp = s.substring(i - 2, i);
                int c = tmp.compareTo("10") >= 0 && tmp.compareTo("25") <= 0 ? a + b : a;
                b = a;
                a = c;
            }
            return a;
        }
    }
}
